import axios from "./axios";

class User {
    constructor(){}

    login(userName:string, password:string, ttc:string){
        let data = {"username": userName, "password": password, "ttc": ttc};
        return axios.post('/login', data)
    }

    register(userName:string, password:string, ttc:string, nickName:string){
        let data = {"username": userName, "password": password, "ttc": ttc, "nickName": nickName};
        return axios.post('/anonymous/api/ttc/register', data)
    }

    getUserInfo(){
        return axios.post('/api/user/getUserInfo', {})
    }

    logout(){
        return axios.post('/logout', {})
    }

    updatePassword(oldPassword:string, newPassword:string){
        return axios.post('/api/user/updatePwd', {
            "password": newPassword,
            "oldPassword": oldPassword
        });
    }
    
}

export default new User();